import {defineStore} from "pinia";

export const infoStore = defineStore('infoStore', {
    state() {
        return {
            orderNum: 0,
            addressList: [
                {
                    id: 1,
                    customerName: 'stx',
                    phone: '188****8888',
                    defaultAddress: true,
                    fullAddress: '浙江省温州市瓯海区茶山高教园区温州大学学生公寓B区'
                },
                {
                    id: 2,
                    customerName: '测试',
                    phone: '123****4567',
                    defaultAddress: false,
                    fullAddress: '浙江省温州市测试测试测试测试测试测'
                }],
            address:
                {
                    id: 1,
                    customerName: 'stx',
                    phone: '188****8888',
                    defaultAddress: true,
                    fullAddress: '浙江省温州市瓯海区茶山高教园区温州大学学生公寓B区'
                },

            order: [],
            totalPrice: 0,
            product: [],
        }
    },
    getters: {
        testGetters() {
            return this.name + '...';//直接利用this便能够获取到里面的内容不需要使用state中间对象
        }
    },
    actions: {
        updateOrderNum: function (value) {
            this.orderNum = value
        },
        updateAddress: function (value) {
            this.address = value;
        },
        insertAddressList: function (value) {
            this.addressList.push(value)
        },
        removeAddressList: function (value) {
            this.addressList.remove(value)
        },
        updateOrder: function (value) {
            this.order = value
        },
        updateTotalPrice: function (value) {
            this.totalPrice = value
        },
        updateProdct: function (value) {
            this.product = value
        }
    }
})